package svgedit.gui.commands;

import svgedit.svg.SVGLength;
import svgedit.svg.SVGStylable;

/**
 * Handles undoing and redoing of stroke width changes
 * @author SARJ
 *
 */
public class ChangeStrokeWidthCommand implements Command
{

	SVGStylable element;
	SVGLength oldLength = new SVGLength();
	SVGLength newLength;

	/**
	 * Constructs the command that will change the width of the element
	 * @param element The element to style
	 * @param newLength the new length to give it - SVGLength
	 */
	public ChangeStrokeWidthCommand(SVGStylable element, SVGLength newLength)
	{
		this.element = element;
		this.oldLength.setValueFromLength(element.getStrokeWidth());
		this.newLength = newLength;
	}

	@Override
	public void executeUndo()
	{
		element.getStrokeWidth().setValueFromLength(oldLength);
	}

	@Override
	public void executeRedo()
	{
		element.getStrokeWidth().setValueFromLength(newLength);
	}
	

}
